<%@ Page Title="" MasterPageFile="~/BackOffice.master" Language="C#" AutoEventWireup="true" CodeBehind="CadastroPerfil.aspx.cs" Inherits="MakeIT.SGI.ERP.Apresentacao.CadastroPerfil" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<asp:Content ID="cHeadHttpEquiv" ContentPlaceHolderID="headHttpEquiv" runat="server">
</asp:Content>
<asp:Content ID="cHead" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="cCadastro" ContentPlaceHolderID="cphTituloCadastro" runat="server">
    Cadastro de Perfil (perfil)
</asp:Content>

<asp:Content ID="cMain" ContentPlaceHolderID="cphMain" runat="server">

    <asp:UpdatePanel ID="upnPerfil" runat="server">
        <ContentTemplate>
            <asp:TabContainer ID="tabPerfil" runat="server" ActiveTabIndex="0">
                <asp:TabPanel ID="tabPesquisa" runat="server" HeaderText="Pesquisa">
                    <ContentTemplate>
                        <div style="width: 100%; background-color:#eeeeff; min-width:400px; min-height:300px;">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td valign="middle" style="width:24px;">
                                        <asp:ImageButton ID="ibPesquisa" runat="server" OnClick="btnPesquisa_Click" 
                                                  ImageUrl="~/App_Themes/Padrao/Imagens/backoffice/search.png" 
                                                  ToolTip="Executa a pesquisa aplicando os filtros"/>
                                    </td>
                                    <td valign="middle" align="left">
                                        Filtros:
                                    </td>
                                    <td>
                                        <div class="FormDiv">
                                            <div class="FormLabel">C&oacute;digo:</div>
                                            <asp:TextBox ID="txtIdPerfil" MaxLength="11" Width="76px" 
                                                onkeypress="strictNum();" onblur="validaDecimal(this.value,11,0);" 
                                                ForeColor="DarkBlue" Font-Bold="True" runat="server"></asp:TextBox>
                                            <asp:MaskedEditExtender ID="meetxtIdPerfil" runat="server" Mask="99999999999" 
                                                TargetControlID="txtIdPerfil" PromptCharacter="" CultureAMPMPlaceholder="" 
                                                CultureCurrencySymbolPlaceholder="" CultureDateFormat="" 
                                                CultureDatePlaceholder="" CultureDecimalPlaceholder="" 
                                                CultureThousandsPlaceholder="" CultureTimePlaceholder="" Enabled="True" />
                                        </div>
                                        <div class="FormDiv">
                                            <div class="FormLabel">Perfil:</div>
                                            <asp:TextBox ID="txtPerfil" MaxLength="60" Width="100px" ForeColor="DarkBlue" 
                                                Font-Bold="True" runat="server"></asp:TextBox>
                                        </div>
                                        <div class="FormDiv">
                                            <div class="FormLabel">Filial:</div>
                                            <asp:DropDownList ID="ddlIdFilial" ForeColor="DarkBlue" 
                                                Font-Bold="True" runat="server" DataTextField="Filial" 
                                                DataValueField="PKString" ></asp:DropDownList>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                            <hr />
                            <asp:GridView ID="grvResultado" runat="server" AutoGenerateColumns="False" EmptyDataText="N&atilde;o foram encontrados registros nessa pesquisa!"
                                  CellPadding="1" ForeColor="#333333" EnableModelValidation="True" >
                                <Columns>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:ImageButton ID="imgbVisualizar" runat="server" OnClick="imgbVisualizar_Click"
                                                ImageUrl="~/App_Themes/Padrao/imagens/backoffice/editar.gif" CommandArgument='<%#Eval("PKString") %>'
                                                ToolTip="Abrir formulário completo" />
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="idPerfil" HeaderText="C&oacute;digo" DataFormatString="{0:N0}"/>
                                    <asp:BoundField DataField="perfil" HeaderText="Perfil"/>
                                    <asp:BoundField DataField="idFilialVO" HeaderText="Filial"/>
                                </Columns>
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <EditRowStyle BackColor="#999999" />
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            </asp:GridView>
                        </div>
                    </ContentTemplate>
                </asp:TabPanel>
                <asp:TabPanel ID="tabCadastro" runat="server" HeaderText="Cadastro">
                    <ContentTemplate>
                        <asp:Panel ID="panelCad" runat="server" BackColor="#eeeeee">
                            <div style="width: 100%; min-width:400px; min-height:300px;">
                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>
                                            <asp:Panel ID="panelBotoes" runat="server">
                                                <asp:Button ID="btnSalvar" runat="server" Enabled="False" ValidationGroup="Salvar"
                                                    OnClick="btnSalvar_Click" Text="Salvar" UseSubmitBehavior="false"/>
                                                &nbsp;<asp:Button ID="btnCancelar" runat="server" OnClick="btnCancelar_Click" 
                                                    Text="Cancelar" UseSubmitBehavior="false"/>
                                                <asp:Button ID="btnEditar" runat="server" Enabled="False" 
                                                    OnClick="btnEditar_Click" Text="Editar" UseSubmitBehavior="false"/>
                                                &nbsp;<asp:Button ID="btnExcluir" runat="server" Enabled="False" 
                                                    OnClick="btnExcluir_Click" Text="Excluir" UseSubmitBehavior="false"/>
                                                &nbsp;<asp:Button ID="btnNovo" runat="server" 
                                                    OnClick="btnNovo_Click" Text="Novo" UseSubmitBehavior="false"/>
                                                <asp:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="btnExcluir" ConfirmText="Confirma a exclus&atilde;o de Perfil?">
                                                </asp:ConfirmButtonExtender>
                                                <hr />
                                            </asp:Panel>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <div class="FormDiv">
                                                <div class="FormLabel">C&oacute;digo:</div>
                                                <asp:TextBox ID="txtCadIdPerfil" MaxLength="11" Width="76" onkeypress="strictNum();" onblur="validaDecimal(this.value,11,0);" ForeColor="DarkBlue" Font-Bold="true" runat="server"></asp:TextBox>
                                                <asp:MaskedEditExtender ID="meetxtCadIdPerfil" runat="server" Mask="99999999999" TargetControlID="txtCadIdPerfil" PromptCharacter="" />
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <div class="FormDiv">
                                                <div class="FormLabel">Perfil:</div>
                                                <asp:TextBox ID="txtCadPerfil" MaxLength="60" Width="350" ForeColor="DarkBlue" Font-Bold="true" runat="server"></asp:TextBox>
                                                <asp:RequiredFieldValidator ControlToValidate="txtCadPerfil" 
                                                   ErrorMessage="Preenchimento obrigat&oacute;rio." ID="rfvtxtCadPerfil" Display="None"
                                                   runat="server" ValidationGroup="Salvar" ></asp:RequiredFieldValidator>
                                                <asp:ValidatorCalloutExtender ID="vcetxtCadPerfil" runat="server" TargetControlID="rfvtxtCadPerfil"></asp:ValidatorCalloutExtender>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <div class="FormDiv">
                                                <div class="FormLabel">Filial:</div>
                                                <asp:DropDownList ID="ddlCadIdFilial" ForeColor="DarkBlue" Font-Bold="true" runat="server" DataTextField="Filial" 
                                                    DataValueField="PKString" ></asp:DropDownList>
                                                <asp:RequiredFieldValidator ControlToValidate="ddlCadIdFilial" InitialValue="-1"
                                                   ErrorMessage="Preenchimento obrigat&oacute;rio." ID="rfvDdlCadIdFilial" Display="None"
                                                   runat="server" ValidationGroup="Salvar" ></asp:RequiredFieldValidator>
                                                 <asp:ValidatorCalloutExtender ID="vceDdlCadIdFilial" runat="server" TargetControlID="rfvDdlCadIdFilial"></asp:ValidatorCalloutExtender>
                                                <asp:HyperLink ID="HyperLinkCadIdFilial" runat="server" NavigateUrl="~/CadastroFilial.aspx" ImageUrl="~/App_Themes/Padrao/Imagens/backoffice/editar.gif" Target="CadastroIdFilial" ToolTip="Editar cadastro" ></asp:HyperLink>
                                                <asp:ImageButton ID="ImageButtonCadIdFilial" runat="server" ImageUrl="~/App_Themes/Padrao/Imagens/backoffice/atualizar.png" ToolTip="Atualizar lista" OnClick="atualizarDdlidFilial" />
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <hr />
                                            <table  border="0" cellpadding="0" cellspacing="3">
                                                <tr>
                                                    <td class="FormLabel">
                                                        Data Cadastro:
                                                    </td>
                                                    <td class="FormLabel">
                                                        Cadastrado por:
                                                    </td>
                                                    <td class="FormLabel">
                                                        Data Edi&ccedil;&atilde;o:
                                                    </td>
                                                    <td class="FormLabel">
                                                        Editado por:
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="FormControl">
                                                        <asp:Literal ID="ltDataCadastro" runat="server"></asp:Literal>
                                                    </td>
                                                    <td class="FormControl">
                                                        <asp:Literal ID="ltCadastradoPor" runat="server"></asp:Literal>
                                                    </td>
                                                    <td class="FormControl">
                                                        <asp:Literal ID="ltDataEdicao" runat="server"></asp:Literal>
                                                    </td>
                                                    <td class="FormControl">
                                                        <asp:Literal ID="ltEditadoPor" runat="server"></asp:Literal>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </asp:Panel>
                    </ContentTemplate>
                </asp:TabPanel>
                <asp:TabPanel ID="tabPerfilxobjeto" runat="server" HeaderText="Perfil&nbsp;X&nbsp;Objeto">
                    <ContentTemplate>
                        <asp:Panel ID="panelPerfilxobjeto" runat="server" BackColor="#eeeeee">
                            <div style="width: 100%; min-width:400px; min-height:300px;">
                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>
                                            <div class="FormLabel">Perfil:</div>
                                            <div class="FormControl">
                                                <asp:Literal ID="ltCadPerfilxobjetoPerfil" runat="server"></asp:Literal>
                                             </div>
                                             <hr />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Panel ID="panelCadPerfilxobjetoBotoes" runat="server">
                                                <asp:Button ID="btnCadPerfilxobjetoSalvar" runat="server" Enabled="False" ValidationGroup="UsuarioxobjetoSalvar"
                                                    OnClick="btnCadPerfilxobjetoSalvar_Click" Text="Salvar" UseSubmitBehavior="false"/>
                                                &nbsp;<asp:Button ID="btnCadPerfilxobjetoCancelar" runat="server" OnClick="btnCadPerfilxobjetoCancelar_Click" 
                                                    Text="Cancelar" UseSubmitBehavior="false"/>
                                                <asp:Button ID="btnCadPerfilxobjetoEditar" runat="server" Enabled="False" 
                                                    OnClick="btnCadPerfilxobjetoEditar_Click" Text="Editar" UseSubmitBehavior="false"/>
                                                
                                                <hr />
                                            </asp:Panel>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:GridView ID="gvPerfilXObjetos" runat="server" AutoGenerateColumns="False" EmptyDataText="N&atilde;o foram encontrados registros!"
                                                CellPadding="1" ForeColor="#333333" GridLines="Both" RowStyle-ForeColor="#333333" Enabled="false"
                                                RowStyle-BackColor="#F7F6F3" OnRowDataBound="gvPerfilXObjetos_RowDataBound">
                                                <Columns>
                                                    <asp:TemplateField HeaderText="Visivel" ItemStyle-HorizontalAlign="Center" >
                                                        <HeaderTemplate>
                                                            <asp:CheckBox ID="cbVisivelTodos" runat="server" AutoPostBack="True" OnCheckedChanged="cbVisivelTodos_CheckedChanged" />
                                                            &nbsp;<asp:Label ID="Label2" runat="server" Text="Visivel"></asp:Label>
                                                            &nbsp;<asp:ImageButton ID="btnResetVisivel" runat="server" ImageUrl="~/App_Themes/Padrao/Imagens/backoffice/reset.png"
                                                                OnClick="btnResetVisivel_Click" ToolTip="Desfazer seleções" />
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <asp:HiddenField ID="hfIdObjeto" runat="server" Value='<%#Eval("PKString") %>' />
                                                            <asp:CheckBox ID="cbVisivel" runat="server" />
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Habilitado" ItemStyle-HorizontalAlign="Center" >
                                                        <HeaderTemplate>
                                                            <asp:CheckBox ID="cbHabilitadoTodos" runat="server" AutoPostBack="True" OnCheckedChanged="cbHabilitadoTodos_CheckedChanged" />
                                                            &nbsp;<asp:Label ID="Label1" runat="server" Text="Habilitado"></asp:Label>
                                                            &nbsp;<asp:ImageButton ID="btnResetHabilitado" runat="server" ImageUrl="~/App_Themes/Padrao/Imagens/backoffice/reset.png"
                                                                OnClick="btnResetHabilitado_Click" ToolTip="Desfazer seleções" />
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <asp:CheckBox ID="cbHabilitado" runat="server" />
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:BoundField DataField="descricao" HeaderText="Descri&ccedil;&atilde;o" />
                                                    <asp:BoundField DataField="objeto" HeaderText="Objeto" />
                                                </Columns>
                                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333"></RowStyle>
                                                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                <EditRowStyle BackColor="#999999" />
                                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                            </asp:GridView>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                   </table>
                                    <hr />
                            </div>
                        </asp:Panel>
                    
</ContentTemplate>
                


</asp:TabPanel>

<asp:TabPanel ID="tabCadPerfilxusuario" runat="server" HeaderText="Perfil&nbsp;X&nbsp;Usu&aacute;rio">
                    <ContentTemplate>
                        <asp:Panel ID="panelPerfilxusuario" runat="server" BackColor="#eeeeee">
                            <div style="width: 100%; min-width:400px; min-height:300px;">
                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>
                                            <div class="FormLabel">Perfil:</div>
                                            <div class="FormControl">
                                                <asp:Literal ID="ltCadPerfilxusuarioPerfil" runat="server"></asp:Literal>
                                             </div>
                                             <hr />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Panel ID="panelCadPerfilxUsuarioBotoes" runat="server">
                                                <asp:Button ID="btnCadPerfilxUsuarioSalvar" runat="server" Enabled="False" ValidationGroup="UsuarioxobjetoSalvar"
                                                    OnClick="btnCadPerfilxUsuarioSalvar_Click" Text="Salvar" UseSubmitBehavior="false"/>
                                                &nbsp;<asp:Button ID="btnCadPerfilxusuarioCancelar" runat="server" OnClick="btnCadPerfilxusuarioCancelar_Click" 
                                                    Text="Cancelar" UseSubmitBehavior="false"/>
                                                <asp:Button ID="btnCadPerfilxUsuarioEditar" runat="server" Enabled="False" 
                                                    OnClick="btnCadPerfilxUsuarioEditar_Click" Text="Editar" UseSubmitBehavior="false"/>
                                                
                                                <hr />
                                            </asp:Panel>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:GridView ID="gvPerfilxUsuarios" runat="server" AutoGenerateColumns="False" EmptyDataText="N&atilde;o foram encontrados registros!"
                                                CellPadding="1" ForeColor="#333333" RowStyle-ForeColor="#333333"
                                                RowStyle-BackColor="#F7F6F3" Enabled="false"
                                                OnRowDataBound="gvPerfilxUsuarios_RowDataBound" EnableModelValidation="True">
                                                <Columns>
                                                    <asp:TemplateField HeaderText="Pertence" ItemStyle-HorizontalAlign="Center">
                                                        <HeaderTemplate>
                                                            <asp:CheckBox ID="cbPertenceTodos" runat="server" AutoPostBack="True" 
                                                                OnCheckedChanged="cbPertenceTodos_CheckedChanged" />
                                                            &nbsp;<asp:Label ID="Label1" runat="server" Text="Pertence"></asp:Label>
                                                            &nbsp;<asp:ImageButton ID="btnResetPertence" runat="server" ImageUrl="~/App_Themes/Padrao/Imagens/backoffice/reset.png"
                                                                OnClick="btnResetPertence_Click" ToolTip="Desfazer seleções" />
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <asp:HiddenField ID="hfIdPerfil" runat="server" Value='<%#Eval("PKString") %>' />
                                                            <asp:CheckBox ID="cbPertence" runat="server" />
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:BoundField DataField="user" HeaderText="Operadores&nbsp;do&nbsp;Sistema" />
                                                </Columns>
                                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333"></RowStyle>
                                                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                <EditRowStyle BackColor="#999999" />
                                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                            </asp:GridView>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <hr />
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </asp:Panel>
                    
</ContentTemplate>
                


</asp:TabPanel>
            </asp:TabContainer>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
